package com.taichuan.keysupport.view.panel;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;

import com.taichuan.keysupport.panel.PanelManager;
import com.taichuan.keysupport.panel.T12KeyBoardPanelManager;

/**
 * Created by OISNY on 2016/8/19.
 */
public class T12KSPanelEditText extends TcPanelEditText {
    private static final String TAG = T12KSPanelEditText.class.getSimpleName();

    public T12KSPanelEditText(Context context) {
        super(context);
    }

    public T12KSPanelEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public T12KSPanelEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    /**
     * 定义一个 太川按键版 【12键】 设备专用的 EditText 按键事件监听回调对象
     */
    private final OnKeyListener tcKeyListener = new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            Log.i(TAG, "onKey:  接收到按键事件：  " + keyCode);
            if (panelManager != null) {
                panelManager.onKeyDown(keyCode);
            }
            return true;
        }
    };

    @Override
    protected OnKeyListener setTcKeyListener() {
        return tcKeyListener;
    }

    @Override
    protected PanelManager initPanelManager(Context context) {
        return new T12KeyBoardPanelManager(context);
    }
}